<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>后台项目管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" th:href="@{/layui/dist/css/view.css}"/>
  <link rel="stylesheet" th:href="@{/layui/dist/css/layui.css}"  media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body class="layui-view-body">
	<div class="layui-content">
        <div class="layui-page-header">
            <div class="pagewrap">
                <div class="pagewrap" style="height: 80px;">
                    <div style="margin-left: 50px;margin-top: 30px;">
                        <font size="6">用户信息</font>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="form-box">
                        <form th:action="@{/userList}">
                            <div class="layui-form layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-form-mid">类型:</div>
                                    <div class="layui-input-inline" style="width: 100px;">
                                        <select  name="type">
                                            <option value="">请选择</option>
                                            <option th:selected="${type == '1'}" value="1">需求方</option>
                                            <option th:selected="${type == '2'}"  value="2">开发方</option>
                                        </select>
                                    </div>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <div class="layui-form-mid">状态:</div>
                                    <div class="layui-input-inline" style="width: 100px;">
                                        <select  name="state">
                                            <option value="">请选择</option>
                                            <option th:selected="${state == '1'}" value="1">封停</option>
                                            <option th:selected="${state == '2'}" value="2">未封停</option>
                                        </select>
                                    </div>
                                    <button class="layui-btn layui-btn-blue" type="submit">查询</button>
                                </div>
                            </div>
                        </form>
                        <!--<button class="layui-btn layui-btn-blue"><i class="layui-icon">&#xe654;</i>新增</button>-->
                        <table class="layui-table">
                            <colgroup>
                                <col width="150">
                                <col width="130">
                                <col>
                            </colgroup>
                            <thead>
                            <tr>
                                <th>用户编号</th>
                                <th>用户姓名</th>
                                <th>用户类型</th>
                                <th>用户状态</th>
                                <th>联系方式</th>
                                <th>email</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="codeUsers:${list}">
                                <td th:text="${codeUsers.userNo}">1001</td>
                                <td th:text="${codeUsers.username}">Tom</td>
                                <td th:text="${codeUsers.type == 2 ? '开发方' : '需求方'}">开发方</td>
                                <td th:text="${codeUsers.state == 1 ? '封停' : '未封停'}">封停</td>
                                <td th:text="${codeUsers.phoneNum}">12345678998</td>
                                <td th:text="${codeUsers.email}">12345678@qq.com</td>
                                <td>
                                    <button class="layui-btn layui-btn-sm" type="button" th:onclick="'showUserDetail(' + ${codeUsers.userNo} + ')'">查看详情</button>
                                    <a class="layui-btn layui-btn-sm layui-btn-normal" th:href="@{/updateUser(userNo=${codeUsers.userNo})}" >启用</a>
                                    <a class="layui-btn layui-btn-sm layui-btn-warm" th:href="@{/modifyUser(userNo=${codeUsers.userNo})}">禁用</a>
                                    <button class="layui-btn layui-btn-sm layui-btn-danger" type="button" th:onclick="'deletefm(' +${codeUsers.userNo} + ')'">删除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <!--分页导航-->
                        <div class="pagination center pagination-large pt-20" style="margin-left: 30%">
                            <div class="row text-center">
                                <div class="col-md-12">
                                    <ul class="pagination">
                                        <li><a th:class="${currentPage eq 1 ? 'btn disabled' : '' }" href="javascript:;" th:href="@{/userList(page=1,type=${type},state=${state})}">首页</a></li>
                                        <li><a th:class="${currentPage eq 1 ? 'btn disabled' : '' }" href="javascript:void(0);" th:href="@{/userList(page=${currentPage}-1,type=${type},state=${state})}">&laquo;</a></li>

                                        <li th:class="${page eq currentPage} ? 'active' : ''" th:each="page:${#numbers.sequence(1,totalPage)}">
                                            <a href="javascript:void(0);" th:href="@{/userList(page=${page},type=${type},state=${state})}" th:text="${page}">1</a>
                                        </li>

                                        <li><a th:class="${currentPage eq totalPage ? 'btn disabled' : '' }" href="javascript:void(0);" th:href="@{/userList(page=${currentPage}+1,type=${type},state=${state})}">&raquo;</a></li>
                                        <li><a th:class="${currentPage eq totalPage ? 'btn disabled' : '' }" href="#" th:href="@{/userList(page=${totalPage},type=${type},state=${state})}" style="border: 1px solid #ddd;">尾页</a></li>
                                        <li><a style="border: 0px;margin-left: 0px;">当前页<span th:text="${currentPage}"></span>/<span th:text="${totalPage}"></span>总页</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--&lt;!&ndash; 显示用户信息的按钮 &ndash;&gt;-->

    <script th:src="@{/layui/dist/layui.all.js}" charset="utf-8"></script>
    <script th:src="@{/js/jquery.min.js}" charset="utf-8"></script>
<script>
    //弹出层 显示用户详细信息
    function showUserDetail(userNo){
        layer.open({
            //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
            type:2,
            title:"用户详细信息",
            area: ['80%','80%','left:126px'],
            content:'/code/userDetail?userNo=' + userNo
        });

    }

    //询问层 删除用户
    function deletefm(userNo) {
        //询问框
        layer.confirm('确认要删除？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            //发送ajax异步删除
            $.ajax({
                ////
                url : '/code/deleteCodeUsers?userNo=' + userNo,
                method :'post',
                data : {userNo:userNo},
                success : function (data) {
                    layer.msg('删除成功', {icon: 1},function () {
                        //重新加载页面
                        layer.load(1);
                        window.location.reload(true);
                    });
                }
            })
        }, function(){
            // layer.alert("取消删除");
        });
    }
</script>

</body>
</html>
